package com.game.states;

import java.util.HashMap;
import java.util.Map;

public class StateFactory {
	public static final Map<Integer, Class> allstate = new HashMap<Integer, Class>();
	public static final int ActionStand = 1;
	public static final int ActionWalk = 2;
	public static final int ActionSleep = 3;
	
	private static final boolean inited = false;
	
	private static void initallstate(){
		allstate.put(ActionStand, StandState.class);
		allstate.put(ActionWalk, WalkState.class);
		allstate.put(ActionSleep, SleepState.class);
	}
	public static ActionState createState(int id){
		if(!inited){
			initallstate();
		}
		if(allstate.containsKey(id)){
			Class cl = allstate.get(id);
			try {
				return (ActionState)cl.newInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}
